﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using ToDoClear.HandleLogic;
namespace ToDoClear
{
    
    public partial class MainPage : PhoneApplicationPage
    {
        private static string TAG = "MainPage";

        public MainPage()
        {
            InitializeComponent();
           
            ToDoCanvas.Init(LayoutRoot);
            HandleManager.getInstance();

            ToDoList testList = new ToDoList();
             

            for (int i = 0; i < 34; i++)
            {
                ToDoItem newItem = new ToDoItem("test"+i);
                testList.AddItem(newItem);
            }
            
            testList.ReSize();
            ToDoCanvas.RootTree().Add(testList);
            ToDoCanvas.getInstance().cuList = testList; 
        }

        void scroll_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
        {
            
        }
        

        #region 事件处理


        private void GestureListener_DragCompleted(object sender, DragCompletedGestureEventArgs e)
        {
             
            Log.d(TAG, "GestureListener_DragCompleted" + e.GetPosition(LayoutRoot).ToString());
 
            HandleManager.currentHanlder.DragCompleted(sender, e);
        }

        private void GestureListener_DragDelta(object sender, DragDeltaGestureEventArgs e)
        {
            Log.d(TAG, "GestureListener_DragDelta" + e.GetPosition(LayoutRoot).ToString());
 
            HandleManager.currentHanlder.DragDelta(sender, e);

        }

        private void GestureListener_DragStarted(object sender, DragStartedGestureEventArgs e)
        {
            Point cuPoint = e.GetPosition(ToDoCanvas.getInstance().RootCanvas);
            ToDoCanvas.getInstance().context.DragStartPoint = cuPoint;

            Log.d(TAG, "GestureListener_DragStarted" + e.GetPosition(LayoutRoot).ToString());
 
            HandleManager.currentHanlder.DragStarted(sender, e);


        }

        private void GestureListener_Flick(object sender, FlickGestureEventArgs e)
        {
 
            HandleManager.currentHanlder.Flick(sender, e);

        }

        private void GestureListener_GestureBegin(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
        {
 
            HandleManager.currentHanlder.GestureBegin(sender, e);

        }

        private void GestureListener_GestureCompleted(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
        {
 
            HandleManager.currentHanlder.GestureCompleted(sender, e);


        }

        private void GestureListener_PinchCompleted(object sender, PinchGestureEventArgs e)
        {
 
            HandleManager.currentHanlder.PinchCompleted(sender, e);


        }

        private void GestureListener_PinchDelta(object sender, PinchGestureEventArgs e)
        {
 
            HandleManager.currentHanlder.PinchDelta(sender, e);


        }

        private void GestureListener_PinchStarted(object sender, PinchStartedGestureEventArgs e)
        {
 
            HandleManager.currentHanlder.PinchStarted(sender, e);


        }

        private void GestureListener_Tap(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
        {
 
            HandleManager.currentHanlder.Tap(sender, e);


        }

        private void GestureListener_Hold(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
        {
           
            HandleManager.currentHanlder.Hold(sender, e);


        }
        #endregion

       

    }
}